// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import Vue from 'vue'
import App from './App'
import router from './router'
import utils from './utils/utils'
import rem from './utils/rem'
import axios from 'axios'
import Mint from 'mint-ui'
import moment from 'moment'
import Vuex from 'vuex'
import VueResource from 'vue-resource'

Vue.use(Mint)
Vue.use(Vuex)
Vue.use(VueResource)
Vue.config.productionTip = false
Vue.prototype.utils = utils
Vue.prototype.axios = axios

import './style/base.css'
import 'mint-ui/lib/style.css'
/**
 * 格式化时间日期
 */
Vue.filter('fmtDate', (value, fmtString) => {
  const lastFmtString = fmtString || 'YYYY-MM-DD HH:mm'
  return moment(value).format(lastFmtString)
})

// 建立传值仓库

const store = new Vuex.Store({
  state() {
    return {
      // 声明
      userMessage: {}, //用户信息
      wxMessage: {}, //微信信息
      wxSet: {}, //微信设置
      isBindTel:false
    }
  },
  // 获取状态
  getters: {
    getUser(state) {
      return state.userMessage
    },
    gettWx(state) {
      return state.wxMessage
    },
    getWxset(state) {
      return state.wxSet
    },
    getBindTel(state){
      return state.isBindTel
    }
  },
  // 变更状态
  mutations: {
    transmitUser(state, value) {
      state.userMessage = value || {}
    },
    transmitWx(state, value) {
      state.wxMessage = value || ''
    },
    transmitWxset(state, value) {
      state.wxSet = value || {}
    },
    transmiBindTel(state,value){
      state.isBindTel = value
    }
  }
})
console.log(store, '仓库')

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
